//
//  BSKAlertView.m
//  MicroMemory
//
//  Created by rimi on 16/7/21.
//  Copyright © 2016年 BlueSky. All rights reserved.
//

#import "BSKAlertView.h"

@implementation BSKAlertView

- (instancetype)init
{
	self = [super init];
	if (self) {
		[self loadUI];
	}
	return self;
}

-(void)loadUI{
	self.frame = [UIScreen mainScreen].bounds;
	UIView * bgView = [[UIView alloc]initWithFrame:self.bounds];
	
	self.backgroundColor = [UIColor clearColor];
	bgView.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.5];
	[self addSubview:bgView];
	self.alpha = 0;
	UITapGestureRecognizer * tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hide)];
	[bgView addGestureRecognizer:tapGesture];
}

-(void)show{
	self.transform = CGAffineTransformMakeScale(1.5, 1.5);
	[UIView animateWithDuration:0.25 animations:^{
		self.transform = CGAffineTransformMakeScale(1, 1);
		self.alpha = 1;
	} completion:^(BOOL finished) {
		
	}];
}

-(void)hide{
	self.transform = CGAffineTransformMakeScale(1, 1);
	[UIView animateWithDuration:0.25 animations:^{
		self.transform = CGAffineTransformMakeScale(1.5, 1.5);
		self.alpha = 0;
	} completion:^(BOOL finished) {
		[self removeFromSuperview];
	}];
}


@end
